from django.contrib.auth.models import Group
from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from meiduo_admin.serializers.admins import AdminsSerialzier
from meiduo_admin.serializers.group import GroupsSerialzier
from meiduo_admin.utils import PageNum
from users.models import User

# 获取管理员用户列表数据
class AdminsView(ModelViewSet):
    serializer_class = AdminsSerialzier
    queryset = User.objects.filter(is_staff=True).order_by("id")
    pagination_class = PageNum

# 获取分组表数据
class GroupsSimpleView(ListAPIView):
    serializer_class = GroupsSerialzier
    queryset = Group.objects.all()